#include <iostream>

using namespace std;

class Int
{
public:

	Int( int n = 0 ) : m_num( n ) { }

	//Int & Display( void )
	//{
	//	cout << m_num;
	//	return *this;
	//}

	Int operator + ( const Int &n )  const 
	{
		return Int( m_num + n.m_num ); 
	}

	int operator + ( const int &n )  const 
	{
		return int( m_num + n ); 
	}

	Int operator / ( const Int &n )  const 
	{
		return Int( m_num / n.m_num ); 
	}

	 friend Int operator + ( int n1, Int n2 ); // Friend method. NOTE: This is NOT a part of the class. this operator doesn't exist!
	 friend ostream & operator << ( ostream &os, Int &n ); // In order for Int to work with cout
	 friend istream & operator >> ( istream &is, Int &n ); // To allow cin functionality

private: 

	int m_num;

};

Int operator + ( int n1, Int n2 ) // We'll make this function a friend of the user-define Int type
{
	return n1 + n2.m_num;
}

ostream & operator << ( ostream &os, Int &n )
{
	os << n.m_num;
	return os;
}

istream & operator >> ( istream &is, Int &n )
{
	is >> n.m_num;
	return is;
}

int main( void )
{
	int num1, num2;
	Int n1(20), n2(10);

	num1 + num2;			  // default data type has default operators (i.e. / * - +) already defined
	cout << (n1 + n2)<<endl;  // User defined type needs to overload operator + in order for this to work // this now works
	cout << (n1 + 10 )<<endl;		  // Overloaded operator + to accept an int
	cout << (10 + n1)<<endl;  // Won't work because the left operand, 10(int), doesn't know what our user-defined Int is..
    cout << (n1 / n2)<<endl;
	//cout << "hello" << "world" << num2 << num1; // sample of daisy-chaining
	//n1.Display().Display().Display().Display(); // sample if daisy-chaining

	cin >> n1;
	cout << endl << n1;
	
}